package com.kevin.v2.spring.formework.aop.aspect;

import com.kevin.v2.spring.formework.aop.intercept.KvMethodInterceptor;
import com.kevin.v2.spring.formework.aop.intercept.KvMethodInvocation;

import java.lang.reflect.Method;

/**
 * 后置通知方法处理
 */
public class KvMethodAfterAdvice extends KvAbstractAspectAdvice implements KvMethodInterceptor {


   private KvJoinPoint joinPoint;


   public KvMethodAfterAdvice (Method aspectMethod, Object aspectTarget) {
      super(aspectMethod, aspectTarget);
   }

   private void after (Object returnValue) {
      super.invokeAdviceMethod(joinPoint, returnValue, null);
   }

   @Override
   public Object invoke (KvMethodInvocation methodInvocation) throws Throwable {
      joinPoint = methodInvocation;

      Object returnValue = methodInvocation.proceed();

      after(returnValue);

      return returnValue ;
   }

}
